package com.centling.bluecollar.login.entity;
import java.util.HashSet;  
import java.util.Set;  
  
import javax.persistence.Column;  
import javax.persistence.Entity;  
import javax.persistence.FetchType;  
import javax.persistence.GeneratedValue;  
import javax.persistence.Id;  
import javax.persistence.JoinColumn;  
import javax.persistence.JoinTable;  
import javax.persistence.ManyToMany;  
import javax.persistence.Table;  
  
import org.hibernate.annotations.GenericGenerator;  
import org.hibernate.annotations.Proxy;  
@Entity  
@Proxy(lazy = false)    
@Table(name = "users", catalog = "mis2013")  
public class User {  
    private String id;  
    private String username;  
    private String password;  
    private boolean enabled;  
    private String description;  
    private Set<Roles> roles = new HashSet<Roles>();  
  
    @GenericGenerator(name = "generator", strategy = "uuid.hex")  
    @Id  
    @GeneratedValue(generator = "generator")  
    @Column(name = "id", unique = true, nullable = false, length = 36)  
    public String getId() {  
        return id;  
    }  
  
    public void setId(String id) {  
        this.id = id;  
    }  
  
    @Column(name = "username", nullable = false, length = 50)  
    public String getUsername() {  
        return username;  
    }  
  
    public void setUsername(String username) {  
        this.username = username;  
    }  
  
    @Column(name = "password", length = 32)  
    public String getPassword() {  
        return password;  
    }  
  
    public void setPassword(String password) {  
        this.password = password;  
    }  
  
    @Column(name = "enabled")  
    public boolean isEnabled() {  
        return enabled;  
    }  
  
    public void setEnabled(boolean enabled) {  
        this.enabled = enabled;  
    }  
  
    @Column(name = "description", length = 255)  
    public String getDescription() {  
        return description;  
    }  
  
    public void setDescription(String description) {  
        this.description = description;  
    }  
  
    @ManyToMany(targetEntity = Roles.class, fetch = FetchType.EAGER)  
    @JoinTable(name = "users_roles", joinColumns = @JoinColumn(name = "users_id"), inverseJoinColumns = @JoinColumn(name = "roles_id"))  
    public Set<Roles> getRoles() {  
        return roles;  
    }  
  
    public void setRoles(Set<Roles> roles) {  
        this.roles = roles;  
    }  
      
}  
